﻿using System.Data.Entity;

namespace GoFishWeb.Models
{
    public class GoFishContext : DbContext
    {
        public GoFishContext() : base("DefaultConnection")
        {
            Configuration.LazyLoadingEnabled = true;
            //Database.SetInitializer(new DataInitializer());
        }

        public DbSet<PlayerRecord> PlayerRecords { get; set; }
        public DbSet<GoFishGame> Games { get; set; }

        /// <summary>
        /// The below Method is used to define the Maping
        /// </summary>
        /// <param name="modelBuilder"></param>
        protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
            modelBuilder.Entity<GoFishMove>()
                        .Property(f => f.OccurredOn)
                        .HasColumnType("datetime2");
        }
    }

    //public class DataInitializer : CreateDatabaseIfNotExists<GoFishContext>
    public class DataInitializer : DropCreateDatabaseIfModelChanges<GoFishContext>
    {

    }
}